var Begin = function (game) {
  this.create = function () {

    var bgClose = game.add.image(0, 0, 'b-0');
    var close = game.add.button(0, 0, imgs['button'], actionOnClick, this, 2, 1, 0);
    close.name = 'close';
    close.width = 1624;
    close.height = 750;

    var groupMain = game.add.group();
    var begin = game.add.image(0, 0, 'begin');

    var next = game.add.button(260, 580, imgs['button'], actionOnClick, this, 2, 1, 0);
    next.width = 380, next.height = 116,next.name='next';
    var milk = game.add.button(717, 550, imgs['button'], actionOnClick, this, 2, 1, 0);
    milk.width = 280, milk.height = 150,milk.name='milk';
    var volume = game.add.button(1062, 550, imgs['button'], actionOnClick, this, 2, 1, 0);
    volume.width = 304, volume.height = 150,volume.name='volume';

    groupMain.add(begin);
    groupMain.add(next);
    groupMain.add(milk);
    groupMain.add(volume);
    groupMain.visible=false;


    var groupMilk = game.add.group();
    var  b_0= game.add.image(0, 0, 'b_0');
    var nextPage = game.add.button(840, 630, imgs['button'], actionOnClick, this, 2, 1, 0);
    nextPage.width = 240, nextPage.height = 50,nextPage.name='nextPage';
    var back = game.add.button(1253, 630, imgs['button'], actionOnClick, this, 2, 1, 0);
    back.width = 140, back.height = 50,back.name='back';

    groupMilk.add(b_0);
    groupMilk.add(nextPage);
    groupMilk.add(back);
    groupMilk.visible=false;



    var groupMilk2 = game.add.group();
    var  b_1= game.add.image(0, 0, 'b_1');
    var backPage = game.add.button(540, 630, imgs['button'], actionOnClick, this, 2, 1, 0);
    backPage.width = 240, backPage.height = 50,backPage.name='backPage';
    var back2 = game.add.button(1253, 630, imgs['button'], actionOnClick, this, 2, 1, 0);
    back2.width = 140, back2.height = 50,back2.name='back2';

    groupMilk2.add(b_1);
    groupMilk2.add(backPage);
    groupMilk2.add(back2);
    groupMilk2.visible=false;


    var groupV = game.add.group();
    var  b_2= game.add.image(0, 0, 'b_2');
    var backV = game.add.button(1253, 630, imgs['button'], actionOnClick, this, 2, 1, 0);
    backV.width = 140, backV.height = 50,backV.name='backV';

    groupV.add(b_2);
    groupV.add(backV);
    groupV.visible=false;


    function actionOnClick(arg) {
      groupMain.visible=false;
      groupMilk.visible=false;
      groupMilk2.visible=false;
      groupV.visible=false;

      switch (arg.name){
        case 'close':{
          close.visible = false;
          bgClose.visible = false;
          groupMain.visible=true;
          break;
        }
        case 'next':{
          game.goState('next');
          break;
        }
        case 'milk':{
          groupMilk.visible=true;
          break;
        }
        case 'volume':{
          groupV.visible=true;
          break;
        }
        case 'back':{
          groupMain.visible=true;
          break;
        }
        case 'back2':{
          groupMain.visible=true;
          break;
        }
        case 'backV':{
          groupMain.visible=true;
          break;
        }
        case 'nextPage':{
          groupMilk2.visible=true;
          break;
        }
        case 'backPage':{
          groupMilk.visible=true;
          break;
        }
      }


    }
  }
}